


public class GameRunner {

	public static void main(String[] args) throws Exception {
		
		int[] score = new int[2];
		int streak = 0;
		int streakCount = 1;
		for (int i = 0; i < 100; i++) {
			System.out.println(i);
			MancalaGameState gs = new KalahPieGameState(4);
			String[] players = new String[2];
			if (args.length > 0)
				players[0] = args[0];
			else
				players[0] = "group1x";
			if (args.length > 1)
				players[1] = args[1];
			else
				players[1] = "group1x";
			
			//double start_time = System.currentTimeMillis()/1000.0;
			TermKalahGame game = new TermKalahGame(gs, players[0], players[1]);
			
			game.play();
			//double elapsed_time = System.currentTimeMillis()/1000.0 - start_time;
			
			//System.out.format("Game completed in %.4f seconds.%n", elapsed_time);
			
			if (game.gs.getScore(0) > game.gs.getScore(1)) {
				score[0]++;
				if (streak != 0) {
					streak = 0;
					System.out.println("1 won " + streakCount + " games.");
					streakCount = 1;
				}
				else {
					streakCount++;
				}
			}
			else if (game.gs.getScore(1) > game.gs.getScore(0)) {
				score[1]++;
				if (streak != 1) {
					streak = 1;
					System.out.println("0 won " + streakCount + " games.");
					streakCount = 1;
				}
				else {
					streakCount++;
				}
			}
			else {
				System.out.println("Tie");
			}
				
			game.player[1].postGameActions(gs);
			game.player[1].actionsBeforeDeletion();
			game.player[0].postGameActions(gs);
			game.player[0].actionsBeforeDeletion();
//			GameStats.printStats(game.gameStates,0);
//			GameStats.printStats(game.gameStates,1);
			//game.player[1].postGameActions(gs);
		}
		
		System.out.println("0: " + score[0] + " 1: " + score[1]);
		
	}
	
}
